import React, { Component } from 'react';
import { createStore } from 'redux';
import { Provider } from 'react-redux';
import Reduxconfig from './redux.config';
import axios from './axios.config';
import Home from './components/home';

const store = createStore(Reduxconfig);

class App extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }
  componentWillMount() {
    store.subscribe(() => {
      //todo let _store = store.getState();
    });
  }
  componentDidMount() {
    axios.get("Http/Msg/MsgStart.ashx?method=Backend_Verifylogin").then(res => {
      if (res.data.flag === "True") {
        store.dispatch({ type: "SET_USERINFO", payload: res.data.result });
      }
    });
  }
  render() {
    return (
      <Provider store={store}>
        <Home routes={this.props.routes} source={this.props.source}></Home>
      </Provider>
    );
  }
}

export default App;
